<template>
  <a-card :bordered="false">
    <!-- 查询区域 时间带时分秒加 :show-time="true" date-format="YYYY-MM-DD HH:mm:ss"-->
    <div class="table-page-search-wrapper">
      <a-form layout="inline" @keyup.enter.native="searchQuery">
        <a-row :gutter="24">

        </a-row>
      </a-form>
    </div>
    <!-- 查询区域-END -->

    <!-- 操作按钮区域 -->
    <div class="table-operator">
      <a-button @click="handleAdd" type="primary" icon="plus">新增</a-button>
      <a-popconfirm title="确定导出吗?" @confirm="() => handleExportXls('房源')">
        <a-button type="primary" icon="download">导出</a-button>
      </a-popconfirm>
      <a-upload name="file" :showUploadList="false" :multiple="false" :headers="tokenHeader" :action="importExcelUrl" @change="handleImportExcel">
        <a-button type="primary" icon="import">导入</a-button>
      </a-upload>
      <!-- 高级查询区域 -->
      <j-super-query :fieldList="superFieldList" ref="superQueryModal" @handleSuperQuery="handleSuperQuery"></j-super-query>
      <a-dropdown v-if="selectedRowKeys.length > 0">
        <a-menu slot="overlay">
          <a-menu-item key="1" @click="batchDel"><a-icon type="delete"/>删除</a-menu-item>
        </a-menu>
        <a-button style="margin-left: 8px"> 批量操作 <a-icon type="down" /></a-button>
      </a-dropdown>
    </div>

    <!-- table区域-begin -->
    <div>
      <div class="ant-alert ant-alert-info" style="margin-bottom: 16px;">
        <i class="anticon anticon-info-circle ant-alert-icon"></i> 已选择 <a style="font-weight: 600">{{ selectedRowKeys.length }}</a>项
        <a style="margin-left: 24px" @click="onClearSelected">清空</a>
      </div>

      <a-table
        ref="table"
        size="middle"
        :scroll="{x:true}"
        bordered
        rowKey="id"
        :columns="columns"
        :dataSource="dataSource"
        :pagination="ipagination"
        :loading="loading"
        :rowSelection="{selectedRowKeys: selectedRowKeys, onChange: onSelectChange}"
        class="j-table-force-nowrap"
        @change="handleTableChange">

        <!-- 文字插槽 -->
        <template slot="textSlot" slot-scope="text">
          <j-text-slot v-model="text" ></j-text-slot>
        </template>

        <!-- 文件插槽 -->
        <template slot="fileSlot" slot-scope="text">
          <j-file-slot v-model="text"></j-file-slot>
        </template>

        <span slot="action" slot-scope="text, record">
          <a @click="handleEdit(record)">编辑</a>
          <a-divider type="vertical"/>
          <a-dropdown>
            <a class="ant-dropdown-link">更多 <a-icon type="down" /></a>
            <a-menu slot="overlay">
              <a-menu-item>
                <a @click="handleDetail(record)">详情</a>
              </a-menu-item>
              <a-menu-item>
                <a-popconfirm :title="'确定'+(record.status==='1'?'下架':'上架')+'吗?'" @confirm="() => handleStatus(record)">
                  <a v-if="record.status==='1'">下架</a>
                  <a v-if="record.status==='2'">上架</a>
                </a-popconfirm>
              </a-menu-item>
              <a-menu-item>
                <a-popconfirm title="确定删除吗?" @confirm="() => handleDelete(record.id)">
                  <a>删除</a>
                </a-popconfirm>
              </a-menu-item>
            </a-menu>
          </a-dropdown>
        </span>

      </a-table>
    </div>
    <house-home-modal ref="modalForm" @ok="modalFormOk"></house-home-modal>
    <!--抽屉页面右侧弹出-->
    <!--<house-home-modal ref="mainDrawer" @ok="modalFormOk"></house-home-modal>-->
  </a-card>
</template>

<script>

  import { httpAction, getAction } from '@/api/manage'
  import '@/assets/less/TableExpand.less'
  import { mixinDevice } from '@/utils/mixin'
  import { JeecgListMixin } from '@/mixins/JeecgListMixin'
  import HouseHomeModal from './modules/HouseHomeModal'
  import {filterMultiDictText} from '@/components/dict/JDictSelectUtil'

  export default {
    name: 'HouseHomeList',
    mixins:[JeecgListMixin, mixinDevice],
    components: {
      HouseHomeModal,
    },
    data () {
      return {
        description: '房源管理页面',
        // 表头
        columns: [
          {
            title: '#',
            dataIndex: '',
            key:'rowIndex',
            width:60,
            align:"center",
            customRender:function (t,r,index) {
              return parseInt(index)+1;
            }
          },
          {
            title:'地址',
            align:"center",
            dataIndex: 'address'
          },
          {
            title:'面积',
            align:"center",
            dataIndex: 'area'
          },
          {
            title:'租金',
            align:"center",
            dataIndex: 'rent'
          },
          {
            title:'封面',
            align:"center",
            dataIndex: 'img',
            scopedSlots: {customRender: 'fileSlot'}
          },
          {
            title:'标签',
            align:"center",
            dataIndex: 'tag'
          },
          {
            title:'所属楼层',
            align:"center",
            dataIndex: 'floor'
          },
          {
            title:'可租时间',
            align:"center",
            dataIndex: 'enableRent',
            customRender:function (text) {
              return !text?"":(text.length>10?text.substr(0,10):text)
            }
          },
          {
            title:'是否可改造',
            align:"center",
            dataIndex: 'enableGz'
          },
          {
            title:'物业费',
            align:"center",
            dataIndex: 'wyRent'
          },
          {
            title:'承重',
            align:"center",
            dataIndex: 'cz'
          },
          {
            title:'消防等级',
            align:"center",
            dataIndex: 'level_dictText'
          },
          {
            title:'所属楼宇',
            align:"center",
            dataIndex: 'building_dictText'
          },
          {
            title:'所属楼栋',
            align:"center",
            dataIndex: 'build_dictText'
          },
          {
            title:'配套',
            align:"center",
            dataIndex: 'pt',
            scopedSlots: {customRender: 'textSlot'}
          },
          {
            title:'描述',
            align:"center",
            dataIndex: 'introduction',
            scopedSlots: {customRender: 'textSlot'}
          },
          {
            title:'详情',
            align:"center",
            dataIndex: 'richText',
            scopedSlots: {customRender: 'textSlot'}
          },
          {
            title:'装修状况',
            align:"center",
            dataIndex: 'zxStatus_dictText'
          },
          {
            title:'轮播图',
            align:"center",
            dataIndex: 'banner',
            scopedSlots: {customRender: 'fileSlot'}
          },
          {
            title:'指导价',
            align:"center",
            dataIndex: 'zdRent'
          },
          {
            title:'房源描述',
            align:"center",
            dataIndex: 'describes',
            scopedSlots: {customRender: 'textSlot'}
          },
          {
            title:'优势卖点',
            align:"center",
            dataIndex: 'advantage',
            scopedSlots: {customRender: 'textSlot'}
          },
          {
            title:'置顶状态',
            align:"center",
            dataIndex: 'isTop_dictText'
          },
          {
            title:'状态',
            align:"center",
            dataIndex: 'status_dictText'
          },
          {
            title:'访问量',
            align:"center",
            dataIndex: 'vistNum'
          },
          {
            title:'房屋类别',
            align:"center",
            dataIndex: 'houseType_dictText'
          },
          {
            title: '操作',
            dataIndex: 'action',
            align:"center",
            fixed:"right",
            width:147,
            scopedSlots: { customRender: 'action' }
          }
        ],
        url: {
          list: "/houseHome/list",
          status: "/houseHome/status",
          delete: "/houseHome/delete",
          deleteBatch: "/houseHome/deleteBatch",
          exportXlsUrl: "/houseHome/exportXls",
          importExcelUrl: "/houseHome/importExcel",
        },
        dictOptions:{},
        superFieldList:[],
        isorter: {
        },
        queryParam: {
           delFlag:'0',
        },
      }
    },
    created() {
      this.getSuperFieldList();
    },
    computed: {
      importExcelUrl: function(){
        return `${window._CONFIG['domianURL']}/${this.url.importExcelUrl}`;
      },
    },
    methods: {
      //这是一个待使用的方法
      mainDataList(record){
        //this.$refs.mainDrawer.title= '【'+record.name +"】 — XXX"
        //this.$refs.mainDrawer.loadList(record);
      },
      initDictConfig(){
      },
      getSuperFieldList(){
        let fieldList=[];
        fieldList.push({type:'Text',value:'address',text:'地址',dictCode:''})
        fieldList.push({type:'BigDecimal',value:'area',text:'面积',dictCode:''})
        fieldList.push({type:'BigDecimal',value:'rent',text:'租金',dictCode:''})
        fieldList.push({type:'string',value:'img',text:'封面',dictCode:''})
        fieldList.push({type:'string',value:'tag',text:'标签',dictCode:''})
        fieldList.push({type:'int',value:'floor',text:'所属楼层',dictCode:''})
        fieldList.push({type:'date',value:'enableRent',text:'可租时间'})
        fieldList.push({type:'string',value:'enableGz',text:'是否可改造',dictCode:''})
        fieldList.push({type:'BigDecimal',value:'wyRent',text:'物业费',dictCode:''})
        fieldList.push({type:'BigDecimal',value:'cz',text:'承重',dictCode:''})
        fieldList.push({type:'string',value:'level',text:'消防等级',dictCode:'level'})
        fieldList.push({type:'string',value:'building',text:'所属楼宇',dictCode:'sxz_building,title,id'})
        fieldList.push({type:'string',value:'build',text:'所属楼栋',dictCode:'house_build,title,id'})
        fieldList.push({type:'Text',value:'pt',text:'配套',dictCode:''})
        fieldList.push({type:'Text',value:'introduction',text:'描述',dictCode:''})
        fieldList.push({type:'Text',value:'richText',text:'详情',dictCode:''})
        fieldList.push({type:'string',value:'zxStatus',text:'装修状况',dictCode:'zxType'})
        fieldList.push({type:'Text',value:'banner',text:'轮播图',dictCode:''})
        fieldList.push({type:'BigDecimal',value:'zdRent',text:'指导价',dictCode:''})
        fieldList.push({type:'Text',value:'describes',text:'房源描述',dictCode:''})
        fieldList.push({type:'Text',value:'advantage',text:'优势卖点',dictCode:''})
        fieldList.push({type:'string',value:'isTop',text:'置顶状态',dictCode:'top_flag'})
        fieldList.push({type:'string',value:'status',text:'状态',dictCode:'status'})
        fieldList.push({type:'int',value:'vistNum',text:'访问量',dictCode:''})
        fieldList.push({type:'string',value:'houseType',text:'房屋类别',dictCode:'sxz_house_type,title,id'})
        this.superFieldList = fieldList
      }
    }
  }
</script>
<style scoped>
  @import '~@assets/less/common.less';
</style>